package com.wanyangproject.androidlearning.multiThread.SuiTangEmpires;

public class ArmRunnable implements Runnable{

    public boolean keepRunning = true;

    @Override
    public void run() {
        String name = Thread.currentThread().getName();
        System.out.println(name+"登场了。。。");
        int count =0;
        while (keepRunning){
            count++;
            System.out.println(String.format("%s发出了第%d次攻击。。。",name,count));
            if (count % 5 == 0){
                Thread.yield();
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            if (count == 100){
                keepRunning = false;
            }
        }
//        System.out.println(String.format("%s结束了战斗。。。",name));
    }


}
